package synchronicity.host;

import synchronicity.agent.Agent;
import synchronicity.calendar.Calendar;
import synchronicity.calendar.Calendar.ModifyCalendarFailedException;
import synchronicity.util.Range;
import synchronicity.util.RangeSet;

public interface SchedulerHost {
	/**
	 * Returns a RangeSet of times that the host is occupied during a specified
	 * date range
	 */
	public RangeSet getBusyTimes(Range range);

	/**
	 * Add a meeting to this host.
	 * 
	 * @param range
	 *            The time of the meeting
	 * @param title
	 *            The title of the meeting
	 * @throws ModifyCalendarFailedException
	 *             If the host rejects the meeting for any reason
	 */
	public void addMeeting(Range range, String title)
			throws ModifyCalendarFailedException;

	/**
	 * Find all other hosts reachable from here.
	 */
	public SchedulerHost[] getHostsReachableFromHere();

	/**
	 * Let an agent visit this node and all nodes reachable from here
	 * @param agent The agent to use
	 * @return The same agent post traversal (may be a different instance or the same)
	 */
	public Agent traverse(Agent agent);

	/**
	 * @return A unique identifier representing this host
	 */
	public String getHostIdentifier();

	public void addMeetingSchedulerListener(MeetingSchedulerListener listener);

	public void removeMeetingSchedulerListener(MeetingSchedulerListener listener);
	
	public Calendar getCalendar();
}
